import React from 'react';
import { connect } from 'dva';
import styles from './index.css';
import Complex from "../../components/Complex";

class ComplexPage extends React.Component {
  render() {
    return (
      <div className={styles.wrapper}>
        <h1>COMPLEX</h1>

        <Complex num={this.props.num} dispatch={this.props.dispatch}/>
      </div>
    );
  }
}

const mapStateToProps = (model) => {
  console.log(model);
  return {num: model.complex.num}; //model.namespace（数据库服务器.数据库实例名称），model.complex.num => this.props.num
}

export default connect(mapStateToProps)(ComplexPage);//mapStateToProps绑定数据，mapDispatchToProps绑定方法（具体实现，略）。简单理解，connect会查下数据库找到所需数据，然后把所需数据绑定到子组件Component的props上
